module.exports = function (sequelize, DataTypes) {
    const User = sequelize.define('User', {
        username: {
            type: DataTypes.STRING,
            //不允许为空
            allowNull: false,
            unique: true,
            comment: '用户名 唯一'
        },
        password: {
            type: DataTypes.STRING,
            //不允许为空
            allowNull: false,
            comment: '密码'
        },
        nickname: {
            type: DataTypes.STRING,
            //不允许为空
            allowNull: false,
            comment: '用户名字'
        },
        roleName: {
            type: DataTypes.STRING,
            comment: '用户角色'
        },
        status: {
            type: DataTypes.BOOLEAN,
            defaultValue: true,
            comment: '用户状态'
        }
    }, {
        timestamps: true, //createAt updateAt是否显示
        createdAt: "createdTime", // 将createdAt设为自定义字段createdTime
        updatedAt: "updatedTime",
        deletedAt: "deletedTime",
        paranoid: true,
    })

    return User;
}

// User.belongsToMany(Role, {
//     through: UserRole,
//     foreignKey: 'userId',
//     otherKey: 'roleId',
//     onUpdate: 'CASCADE',
//     onDelete: 'CASCADE'
// })
//
// Role.belongsToMany(User, {
//     through: UserRole,
//     foreignKey: 'roleId',
//     otherKey: 'userId',
//     onUpdate: 'CASCADE',
//     onDelete: 'CASCADE'
// })


// module.exports = User;
